﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;

namespace Spotless.Data
{
    [MetadataType(typeof(Campaign_Metadata))]
    public partial class Campaign
    {
        public enum CampaignTypes : byte
        {
            DDM = 1,
            Web = 2,
            Email = 3
        }

        public CampaignTypes? CampaignType
        {
            get
            {
                if (this.CampaignTypeId.HasValue)
                    return (CampaignTypes)this.CampaignTypeId;
                else
                    return null;
            }
            set
            {
                if (value.HasValue)
                    this._CampaignTypeId = (byte)value;
                else
                    this._CampaignTypeId = null;
            }
        }

        partial void OnValidate(System.Data.Linq.ChangeAction action)
        {
            if (action == System.Data.Linq.ChangeAction.Insert)
                this._Created = this._Updated = DateTime.Now;
            else if (action == System.Data.Linq.ChangeAction.Update)
                this._Updated = DateTime.Now;
        }
    }

    public class Campaign_Metadata
    {
        //[DisplayName("Id")]
        public int CampaignId { get; set; }

        [Required]
       [DisplayName("Campaign Name")]
       public string CampaignName { get; set; }

       [DisplayName("Campaign Date")]
       public string CampaignDate { get; set; }
        
      // [Required(ErrorMessage = "{0} is required")]
       [DisplayName("Category")]
       public int CampaignType { get; set; }

      // [Required(ErrorMessage = "{0} is required")]
       [DisplayName("Category")]
       public int CategoryId { get; set; }

       [DisplayName("Product")]
       //[Range(1, 1000000, ErrorMessage = "{0} is required")]
       //[Required(ErrorMessage = "{0} is required")]
       public int ProductId { get; set; }

    }
}
